package com.chentongwei.task;

import com.chentongwei.facade.user.service.IUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 用户模块Task
 *
 * @author TongWei.Chen 2017-09-21 13:11:25
 */
@Component
public class UserTask {
    private static final Logger LOG = LoggerFactory.getLogger(UserTask.class);

    @Autowired
    private IUserService userService;

    /**
     * 删除没有激活的用户
     * 每天跑一次小程序删除那些大于两小时还没激活的用户，这些用户被视为无效用户
     */
    @Scheduled(cron = "0 30 03 * * ?")
//    @Scheduled(cron = "0/5 * * * * ?")
    public void deleteUnActiveUser() {
        userService.deleteUnActiveUser();
        LOG.info("------删除未激活的用户成功------");
    }
}
